package com.shruijin.wy.aop.advice;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.BeforeAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.lang.Nullable;

import java.lang.reflect.Method;

/**
 * method 3（原始方式） ：手动添加 advice 、pointcut、proxy方式
 */

public class ActionAdvice3 implements MethodBeforeAdvice,AfterReturningAdvice{

    Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    @Override
    public void before(Method method, Object[] objects, @Nullable Object o) throws Throwable {
        LOGGER.info("{} Pojo方式， 前置通知!",method.getName());
    }

    @Override
    public void afterReturning(@Nullable Object returnValue, Method method, Object[] args, @Nullable Object target) throws Throwable {
        LOGGER.info("{} Pojo方式， 返回通知!",method.getName());
    }
}
